/************************************************************************************
**  
* @copyright (c) 2015-, Technology Co., LTD. All Right Reserved.
*
*************************************************************************************/
/**
* @file     duye_cap_plugin.h
* @version     
* @brief      
* @author   
* @date     2013-01-09
* @note 
*
*  1. 2018-01-09 created this file
* 
*/
#pragma once

#include <string>
#include <vector>
#include <duye_cap_object.h>
#include <duye_cap_service_base.h>
#include <duye_cap_filter.h>
#include <duye_cap_transfer.h>

namespace duye {

/**
 * @brief application plugin base class
 */
class AppPlugin : public CapObject {
public:
	virtual ~AppPlugin() {}

	/**
	 * @brief plugin initializer
	 * @return true/false
	 */	
	virtual bool onInit(ModuleTransfer* transfer) = 0;

	/**
	 * @brief plugin uninitializer
	 * @return true/false
	 */	
	virtual bool onUninit() = 0;

	/**
	 * @brief get the data service component needs by parser plugin
	 * @param [out] fileRule : rule vector
	 */	
	virtual void onGetDataServiceList(DataServiceTypeVector& dataServiceList) = 0;		

	/**
	 * @brief get filter rules, app plugin provide, by called before startup
	 * @param [out] fileRule : rule vector
	 */
	virtual void onGetFilterRule(FilterRule& filterRule) = 0;
};

/**
 * @brief plugin information
 */
class PluginInfo {
public:
    PluginInfo();
    ~PluginInfo();

    void setName(const std::string& name) { m_name = name; }
    const std::string& name() const { return m_name; }

    void setPath(const std::string& path) { m_path = path; }
    const std::string& path() const { return m_path; }

    void setDllHandle(void* dllHandle) { m_dllHandle = dllHandle; }
    void* dllHandle() { return m_dllHandle; }

    void setObject(CapObject* object) { m_object = object; }
    CapObject* object() { return m_object; }

	void setFilterRule(const FilterRule& filterRule) { m_filterRule = filterRule; }
	const FilterRule& filterRule() const { return m_filterRule; }

	void setDataServiceList(const DataServiceTypeVector& dataServiceList) { m_dataServiceList = dataServiceList; }
	const DataServiceTypeVector& dataServiceList() const { return m_dataServiceList; }	
    
private:
    // plugin name, the same of class name
    std::string m_name;
    // library full path
    std::string m_path;
	// library handle
	void* m_dllHandle;
    // object
    CapObject* m_object;
	// plugin rules
	FilterRule m_filterRule;
	// data service list
	DataServiceTypeVector m_dataServiceList;
};

}
